package com.abcd.sort;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @program: java-base
 * @description:
 * @author: Liu
 **/
public class BaseList {

    public static void main(String[] args) {
        Base baseA = new Base();
        Base baseB = new Base();
        BaseProperty baseProperty = new BaseProperty();
        baseProperty.setA(1);
        baseProperty.setB("123");

        BaseProperty basePropertyA = new BaseProperty();
        basePropertyA.setA(2);
        basePropertyA.setB("456");
        baseA.setAge(1);
        baseA.setName("abc");
        baseA.setBaseProperty(baseProperty);
        baseB.setAge(2);
        baseB.setName("bbc");
        baseB.setBaseProperty(basePropertyA);


        List<Base> baseList = new ArrayList<>();
        baseList.add(baseA);
        baseList.add(baseB);


        System.out.println(System.currentTimeMillis());
        System.out.println(baseList);



        // List<Base> collect = baseList.stream().filter(base -> base.getAge() == 1).collect(Collectors.toList());

        List<Base> collect = baseList.stream().filter(base -> base.getBaseProperty().getA() == 2).collect(Collectors.toList());
        baseList.stream().distinct();
        for (int i= 0; i < 100; i ++) {
            System.out.println(collect);
        }

        System.out.println(System.currentTimeMillis());

        BigDecimal bigDecimal = new BigDecimal("1.900");
        int i = bigDecimal.setScale(0, BigDecimal.ROUND_UP).intValue();
        System.out.println(i);

        System.out.println(Runtime.getRuntime().availableProcessors());

    }
}